//
//  MYShopDetailsSpecificationsAddCountCell.swift
//  MuYing
//
//  Created by tbb on 2019/7/29.
//  Copyright © 2019 TBB. All rights reserved.
//Reduction

import UIKit

class MYShopDetailsSpecificationsAddCountCell: UICollectionViewCell,UITextFieldDelegate {
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var reductionBtn: UIButton!
    
    @IBOutlet weak var numTextFiled: UITextField!

    @IBOutlet weak var addBtn: UIButton!
    
    @IBAction func addAction(_ sender: UIButton) {
        let text = self.numTextFiled.text as NSString?;
        guard var num = text?.integerValue else {
            return;
        }
        num = num + 1;
        let numStr = String(num);
        self.numTextFiled.text = numStr;
    }
    
    @IBAction func reductionAction(_ sender: UIButton) {
        let text = self.numTextFiled.text as NSString?;
        guard var num = text?.integerValue else {
            return;
        }
        
        if num < 2 {
            return;
        }
        num = num - 1;
        let numStr = String(num);
        self.numTextFiled.text = numStr;
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        self.numTextFiled.keyboardType = .numberPad;
        self.numTextFiled.delegate = self;
        self.label.text = kYQLSSwift("购买数量");
    }
//    func textFieldDidEndEditing(_ textField: UITextField)
    func textFieldDidEndEditing(_ textField: UITextField) {
        let text = textField.text;
        let nsstringStr = text as NSString?
        
        if let num = nsstringStr?.integerValue , num < 1{
            textField.text = "1";
        }
    }
    
//    override func setSelected(_ selected: Bool, animated: Bool) {
//        super.setSelected(selected, animated: animated)
//
//        
//    }
    
}
